#ifndef _MODOU_SPI_H_
#define _MODOU_SPI_H_
/* Includes ------------------------------------------------------------------*/

#ifdef STM32L071xx
#include "stm32l0xx_hal.h"
#endif

#ifdef STM8L15X_HD
#include "stm8l15x.h"
#endif

typedef enum SPI_TYPE{
  W25Q8_SPI=0,
	ADXL_SPI,
  SPI_ARR_SIZE
}SPI_TYPE;

#define EEPROM_DAC_START_ADDR   DATA_EEPROM_BASE+6             /* Start @ of user EEPROM area */
#define EEPROM_DAC_END_ADDR     (EEPROM_BIAS_START_ADDR + 16)   /* End @ of user EEPROM area */
#define IS_DAC_DATA_ADDRESS(__ADDRESS__)          (((__ADDRESS__) >= EEPROM_DAC_START_ADDR) && ((__ADDRESS__) <= EEPROM_DAC_END_ADDR))
#define IS_DAC_CH_ADDRESS(__ADDRESS__)          (((__ADDRESS__) >= 1) && ((__ADDRESS__) <= 4))

int modou_SPI_Init(int spi_index,GPIO_TypeDef * SCK_PORT, uint16_t SCK_PIN, GPIO_TypeDef * MOSI_PORT,
				uint16_t MOSI_PIN, GPIO_TypeDef * MISO_PORT, uint16_t MISO_PIN,
				GPIO_TypeDef * CS_PORT,	uint16_t CS_PIN);
int modou_SPI_WriteByte(int spi_index,uint8_t dt);
int modou_SPI_ReadByte(int spi_index);
int modou_SPI_ReadWrite_Byte(int spi_index,uint8_t TxData);
int modou_SPI_CS_ENABLE(int spi_index);
int modou_SPI_CS_DISABLE(int spi_index);
int modou_SPI_Un_Init(int spi_index);
#endif
